#include<stdio.h>
#include<string.h>
#include<stdlib.h>
//递归
int my_strlen1(char* str)
{
    if(str == NULL || (*str == '\0'))
        return 0;
    return 1 + my_strlen1(str+1);
}
//指针-指针
int my_strlen2(char* str)
{
    if(str == NULL || (*str == '\0'))
        return 0;
    char* end = str;
    while(*end != '\0')
    {
        end++;
    }
    return end - str; //[start,end)
}
//计数器
int my_strlen3(char* str)
{
    if(str == NULL || (*str == '\0'))
        return 0;
    int count = 0;
    while(*str != '\0')
    {
        count++;
        str++;
    }
    return count;
}
char* strcpy(char* dest,const char* src)
{
    char* ans = dest;
    // while(*src)
    // {
    //     *dest = *src;
    //     dest++;
    //     src++;
    // }
    
    // while(*src)
    // {
    //     *dest++ = *src++;
    // }
    // *dest = '\0';
    

    //while(*dest++ = *src++) ;
    
    return ans;
}
char* strcat(char* dest,const char* src)
{
    char* ans = dest;
    while(*dest)   dest++;
    while(*dest++ = *src++);
    return ans;
}
int main()
{
    char s[20] = {'a','b','c','d','\0'};
    char* str = "hello  Mango ";
    // printf("strlen1:%d\n",my_strlen1(str));
    // printf("strlen2:%d\n",my_strlen2(str));
    // printf("strlen3:%d\n",my_strlen3(str));
    printf("%s\n",strcat(s,str));
    return 0;
}